Progress bar: Handle 'no more pulse'
authorMatthias Clasen <mclasen@redhat.com>
Mon, 11 Nov 2013 12:24:35 +0000 (07:24 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 11 Nov 2013 12:24:35 +0000 (07:24 -0500)
Before smooth animation, stopping the pulse would abruptly stop
the bouncy bar. This change makes it so that we slow down for
a bit, and then stop.

gtk/gtkprogressbar.c

index 00080bb3fd3ddb0b48341a283e4da6cdcf6c90aa..5e3a47d3067d446e3b0b12316fae02bf7470adae 100644 (file)
@@ -588,11 +588,17 @@ tick_cb (GtkWidget     *widget,
   g_assert (priv->pulse2 > priv->pulse1);
   g_assert (frame2 > priv->frame1);
 
+  if (frame2 - priv->pulse2 > 3 * (priv->pulse2 - priv->pulse1))
+    {
+      priv->pulse1 = 0;
+      return G_SOURCE_CONTINUE;
+    }
+
   /* Determine the fraction to move the block from one frame
    * to the next when pulse_fraction is how far the block should
    * move between two calls to gtk_progress_bar_pulse().
    */
-  fraction = priv->pulse_fraction * (frame2 - priv->frame1) / (priv->pulse2 - priv->pulse1);
+  fraction = priv->pulse_fraction * (frame2 - priv->frame1) / MAX (frame2 - priv->pulse2, priv->pulse2 - priv->pulse1);
 
   priv->frame1 = frame2;